n,m=map(int,input().split())
arrs=[]
for i in range(0,n):
    arr=list(map(int,input().split()))
    arrs.append(arr)

res=[[0 for i in range(0,n)] for j in range(0,m)]

for i in range(0,n):
    for j in range(0,m):
        res[m-1-j][i]=arrs[i][j]

for i in range(0,m):
    for j in range(0,n):
        print(res[i][j],end=" ")
    print("")